/**
 * 
 */
package candy;

/**
 * @author Riks
 *
 */
public abstract class Sweet implements Informic {
	
	protected double albumens;
	protected double carbohydrates;
	protected double fats;
	protected int id;
	protected String name;
	protected double price;
	protected double weight;
	
	public Sweet() { }
	public Sweet(int id, String name, double albumens, double fats, double carbohydrates,
			double weight, double price){
		this.id = id;
		this.name = name;
		this.albumens = albumens;
		this.fats = fats;
		this.carbohydrates = carbohydrates;	
		this.weight = weight;
		this.price = price;		
	}
	protected abstract double calculateCalorificValue();	
	
	public double getEnergyValue(){
					return calculateCalorificValue();
		}
	
	public double getAlbumens() {
		return albumens;
	}
	public double getCarbohydrates() {
			return carbohydrates;
		}
	public double getFats() {
		return fats;
	}
	public int getId() {
	return id;
}
	public String getName() {
		return name;
	}
	public double getPrice() {
		return price;
	}
	public double getWeight() {
		return weight;
	}
	public void setAlbumens(double albumens) {
		this.albumens = albumens;
	}
	public void setCarbohydrates(double carbohydrates) {
		this.carbohydrates = carbohydrates;
	}
	public void setFats(double fats) {
		this.fats = fats;
	}
	public void setId(int id) {
		this.id = id;
	}
	public void setPrice(double price) {
		this.price = price;
	}
	public void setWeight(double weight) {
		this.weight = weight;
	}
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		long temp;
		temp = Double.doubleToLongBits(albumens);
		result = prime * result + (int) (temp ^ (temp >>> 32));
		temp = Double.doubleToLongBits(carbohydrates);
		result = prime * result + (int) (temp ^ (temp >>> 32));
		temp = Double.doubleToLongBits(fats);
		result = prime * result + (int) (temp ^ (temp >>> 32));
		result = prime * result + id;
		result = prime * result + ((name == null) ? 0 : name.hashCode());
		temp = Double.doubleToLongBits(price);
		result = prime * result + (int) (temp ^ (temp >>> 32));
		temp = Double.doubleToLongBits(weight);
		result = prime * result + (int) (temp ^ (temp >>> 32));
		return result;
	}
	@Override
	public boolean equals(Object obj) {
		if (this == obj) {
			return true;
		}
		if (obj == null) {
			return false;
		}
		if (!(obj instanceof Sweet)) {
			return false;
		}
		Sweet other = (Sweet) obj;
		if (Double.doubleToLongBits(albumens) != Double
				.doubleToLongBits(other.albumens)) {
			return false;
		}
		if (Double.doubleToLongBits(carbohydrates) != Double
				.doubleToLongBits(other.carbohydrates)) {
			return false;
		}
		if (Double.doubleToLongBits(fats) != Double
				.doubleToLongBits(other.fats)) {
			return false;
		}
		if (id != other.id) {
			return false;
		}
		if (name == null) {
			if (other.name != null) {
				return false;
			}
		} else if (!name.equals(other.name)) {
			return false;
		}
		if (Double.doubleToLongBits(price) != Double
				.doubleToLongBits(other.price)) {
			return false;
		}
		if (Double.doubleToLongBits(weight) != Double
				.doubleToLongBits(other.weight)) {
			return false;
		}
		return true;
	}
	
	

}
